package com.cmcm.network;

import org.aspectj.bridge.IMessage;
import org.gradle.api.Project;
import org.gradle.api.logging.Logger;

/**
 * Created by gezihua on 17-1-4.
 */

public  abstract class NetHandler {

    private String mEncoding;
    private String mOutPath;
    private String mInputPath;
    private String mClassPath;
    private Project mProject;

    public NetHandler(Project project) {
        mProject = project;
        mEncoding = "utf8";
    }

    public Project getProject() {
        return mProject;
    }

    public void setProject(Project project) {
        mProject = project;
    }

    public Logger getLogger(){
        return mProject.getLogger();
    }

    public abstract void handle();

    public void  log(IMessage message){
        Logger log = getLogger();
        IMessage.Kind kind = message.getKind();
            if (IMessage.ABORT.compareTo(kind)==0||IMessage.ERROR.compareTo(kind)==0||IMessage.FAIL.compareTo(kind)==0){
                log.error (message.getMessage(), message.getThrown());
                return;
            }
            if (IMessage.WARNING.compareTo(kind)==0){
                log.warn (message.getMessage(), message.getThrown());
                return;
            }
            if (IMessage.INFO.compareTo(kind)==0){
                log.info (message.getMessage(), message.getThrown());
                return;
            }
            if (IMessage.DEBUG.compareTo(kind)==0){
                log.debug (message.getMessage(), message.getThrown());
                return;
            }
    }

    public String getEncoding(){
        return mEncoding;
    }

    public void setEncoding(String encoding) {
        mEncoding = encoding;
    }
    // 这个里边处理编译的过程

    public String getOutPath(){
        return mOutPath;
    }

    public void setOutPath(String outPath) {
        mOutPath = outPath;
    }

    public String getInputPath(){
        return mInputPath;
    }

    public void setInputPath(String inputPath) {
        mInputPath = inputPath;
    }

    public String getClassPath(){
        return mClassPath;
    }

    public void setClassPath(String classPath) {
        mClassPath = classPath;
    }

}
